﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RectBar;

namespace BayesDraw
{
    public partial class Form1 : Form
    {
        public Graphics FormGraphics;
        public Form1()
        {
            InitializeComponent();
            InitPicBox();
            FormGraphics = this.CreateGraphics();
        }

        private RNode node1;
        private RNode node2;
        private RNode node3;
        private RNode node4;
        private RNode node5;
        private RNode node6;
        private Arrow arrow1;
        private Arrow arrow2;
        private Arrow arrow3;
        private Arrow arrow4;
        private Arrow arrow5;
        private Arrow arrow6;

        private RectCBar bar1;
        private RectCBar bar2;

        private void InitPicBox()
        {
            node1 = new RNode("1", FormGraphics);
            node2 = new RNode("2", FormGraphics);
            node3 = new RNode("3", FormGraphics);
            node4 = new RNode("4", FormGraphics);
            node5 = new RNode("5", FormGraphics);
            node6 = new RNode("6", FormGraphics);

            this.Controls.Add(this.node1);
            this.Controls.Add(this.node2);
            this.Controls.Add(this.node3);
            this.Controls.Add(this.node4);
            this.Controls.Add(this.node5);
            this.Controls.Add(this.node6);

            arrow1 = new Arrow(node1, node2, this);
            arrow2 = new Arrow(node6, node3, this);
            arrow3 = new Arrow(node3, node2, this);
            arrow4 = new Arrow(node6, node5, this);
            arrow5 = new Arrow(node3, node5, this);
            arrow6 = new Arrow(node5, node1, this);

            arrow1.TagStr = "1";
            arrow2.TagStr = "2";
            arrow3.TagStr = "3";
            arrow4.TagStr = "4";
            arrow5.TagStr = "5";
            arrow6.TagStr = "6";


            // ---------------------------------------------

        }




        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            arrow1.DrawArrow();
            arrow2.DrawArrow();
            arrow3.DrawArrow();
            arrow4.DrawArrow();
            arrow5.DrawArrow();
            arrow6.DrawArrow();
            //e.Graphics.DrawImage(Properties.Resources.Round_Blue_64, new PointF(100, 100));

        }


        private void button1_Click(object sender, EventArgs e)
        {
            string result = "";
            foreach (Arrow rNode in node5.InArrows)
            {
                result += rNode.TagStr + "/";
            }
            MessageBox.Show(result);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                arrow1.ChangeEndNode(node6);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }

        private void button3_Click(object sender, EventArgs e)
        {
            RectCBarPanel.PxRatioTime = 8;
        }

        private void timeTrackBar_ValueChanged(object sender, EventArgs e)
        {
            RectCBarPanel.PxRatioTime = timeTrackBar.Value;
        }

        private void btnScrollTest_Click(object sender, EventArgs e)
        {
        }




    }
}
